
#ifndef  RECOVERY_LOG_FILELOG_H
#define  RECOVERY_LOG_FILELOG_H

#include <string>
#include <memory>
#include "recovery/log/ILog.h"

namespace recovery {

namespace fs {
namespace file {
    class FileLogOperation;
}
}

namespace log {


class FileLog : public ILog {
public:
    static const std::string DefaultDir;
    static const std::string DefaultName;

    FileLog(const std::string & name, const std::string & dir);
    ~FileLog() override ;

    int size() const override;
    int remove() override ;
    int truncate(size_t size = 0) override;
    int sync() override ;
    int append(const std::string & data) override ;
    int positionedRead(const size_t offset, uint8_t * buf, const int len) override;

protected:
    int openOnce() override ;
    int closeOnce() override ;
private:
    std::string _name;
    std::string _dir;
    std::string _path;
    std::unique_ptr<recovery::fs::file::FileLogOperation> operation;
};


}// end of namespace log
}// end of namespace recovery

#endif   /* RECOVERY_LOG_FILELOG_H */
